package 二分查找;

public class Solution2 {
    //https://www.nowcoder.com/practice/abc3fe2ce8e146608e868a70efebf62e
    public boolean Find (int target, int[][] array) {
        //题解：
        //思路：线性搜索，从左下角开始，大往右，小往上，不可能左右方向路径
        int currow = array.length - 1;
        int curcol = 0;
        int boundcol = array[0].length - 1;
        int boundrow = 0;
        while (currow >= boundrow && curcol <= boundcol) {
            if(array[currow][curcol] > target) {
                currow--;
            }else if(array[currow][curcol] < target) {
                curcol++;
            }else {
                return true;
            }
        }
        return false;
    }
}
